package com.cc.controller;

import com.cc.comm.exception.ResourceNotFoundException;
import com.cc.comm.responce.R;
import com.cc.model.entity.Book;
import com.cc.service.BookService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 晓东√
 * @since 2025-09-16 10:39
 */
@RestController
@RequestMapping("/book")
@Slf4j
@Tag(name = "书籍管理", description = "书籍管理增删改查")
public class BookController {

    @Autowired
    private BookService bookService;

    //返回使用的书籍列表
    @GetMapping("/list")
    @Operation(summary = "返回书籍列表")
    @Parameters(value = {
            @Parameter(name = "bookName",required = false, description = "书籍名"),
            @Parameter(name = "author",required = true, description = "作者")
    })
    public R<List<Book>> list(
           @RequestParam(required = false) String bookName,
            String author) {
        log.info("返回书籍列表");
        return R.success(bookService.list());
    }
}
